﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data;

public partial class CMS_Admin_GetPic : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind();
        }
    }

    private void Bind()
    {
        string temp = System.Configuration.ConfigurationManager.AppSettings["UsasInformationPath"].ToString() + "Pic\\";
        DirectoryInfo dir = new DirectoryInfo(temp);
        FileInfo[] files = dir.GetFiles("*.jpg");


        DataTable dt = MakeNewWTable();

        for (int i = 0; i < files.Length; i++)
        {
            DataRow SR = dt.NewRow();

            SR["PicName"] = files[i].ToString();
            //SR["Path"] = Request.Url.Scheme + "://" + Request.Url.Authority + "/Usasinformation/Pic/" + files[i].ToString();
            SR["Path"] = System.Configuration.ConfigurationManager.AppSettings["UsasInformationIIS"].ToString() + "Pic/" + files[i].ToString();
            dt.Rows.Add(SR);
        }

        DlPic.DataSource = dt;
        DlPic.DataBind();

    }



    private DataTable MakeNewWTable()
    {
        DataTable WTable = new DataTable("PicTable");
        {

            WTable.Columns.Add(new DataColumn("PicName", typeof(string)));
            WTable.Columns.Add(new DataColumn("Path", typeof(string)));

        }
        return WTable;
    }
}
